const express = require('express')
const app = express()
const port = 5000

app.use(
    (request, response, next) => {
        console.log("有人请求服务器1了");
        console.log("请求的资源是：", request.url);
        console.log("请求来自于：", request.get('Host'));
        next()
    }
)



app.get('/students', (req, res) => {
    const students = [
        { id: '001', name: 'tom', age: 18 },
        { id: '002', name: 'jerry', age: 19 },
        { id: '003', name: 'tony', age: 22 },
    ]
    res.send(students)
})
app.listen(
    port,
    (err) => {
        if (!err){
            console.log(`服务器1启动成功了，请求学生信息地址为：http://localhost:${port}/students`)
        }
    }
)